package com.malie.myspringboot.jdk8;

import cn.hutool.core.date.DateUtil;
import com.malie.myspringboot.test.Person;

import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import java.util.stream.Collectors;

public class Test {
    @org.junit.Test
    public void Test1() {
        Person person = new Person();
        person.setName("马列");
        person.setAge("26");

        Person person1 = new Person();
        person1.setName("一凡");
        person1.setAge("23");
        ArrayList<Person> list = new ArrayList<>();
        list.add(person);
        list.add(person1);

        Map<String, Person> map = list.stream().collect(Collectors.toMap(e -> e.getName(), e -> e));
        System.out.println(map);
        Double collect = list.stream().collect(Collectors.averagingInt(e -> Integer.valueOf(e.getAge())));
        System.out.println(collect);
        long count = list.stream().count();
        System.out.println(count);
    }
    @org.junit.Test
    public void test2(){
        Date date = new Date();

        System.out.println(DateUtil.month(date)+1);
    }
}
